<template>
  <div> 
    <!-- <so-header :seller="headerTitle"></so-header> -->
    <setHeader :title="headerTitle" @done="gotobtn()"></setHeader>
    <div class="pagecontent">

      <!-- 公司同事 -->
      <div class="main-myColl main-company-colleague">
          <div class="title_text_more">
            <h3>{{teamName}}</h3>
          </div>
          <div class="company_list">
              <ul class="main-colleague">
                  <li v-for="wi in checkUserInfo" v-show="checkFlag1" :key="wi.id" @click="goCheckInfo(wi.uid)">
                      <div class="right_img">
                        <img :src="wi.userhead"/>
                      </div>                        
                  </li>
                  <li v-show="checkFlag2" style = "width: 100%; text-align: center; margin-left: 0; padding-bottom: 0;">
                      <span class="noData">—暂无数据—</span>                        
                  </li>
                  <!-- <li v-for="n in Array(10)">
                    <img src="../common/images/cir_07.jpg" alt="">
                  </li> -->
              </ul>
          </div> 
      </div>
    </div>
  </div>


</template>

<script>
import setHeader from '../public/setHeader.vue';
import { MessageBox } from 'mint-ui';

  export default {
    data() {
      return {
        headerTitle:'我的同事',
        userInfo:'',
        JoinList:'',
        value:'',
        cid:'1',
        cpId:'',
        waitUserInfo: '',
        checkUserInfo: '',
        waitFlag1: true,
        waitFlag2: false,
        checkFlag1: true,
        checkFlag2: false,
        isAdmin: false,
        type:'',
        newTeam:'新的同事',
        teamName:'公司同事',
        new_show:false,//同事申请列表
        deId:'',
      };
    },
    components:{
      setHeader,
    },
    created() {
        let that = this;
        that.userInfo = JSON.parse(window.localStorage.getItem('userInfo'));
        //获取当前企业所有成员
        
        that.cpId = this.$route.query.cp_id;
        that.deId = this.$route.query.deId;
        that.getCompanyColleague(that.cpId);
        //获取当前部门同等级的部门信息
        that.getCompanyDepartList();
        that.type = this.$route.query.type;
        if(that.type==1){
          that.headerTitle = '我的员工';
          that.newTeam = '新的申请';
          that.teamName = '所有员工';
          that.new_show = true;
        }
    },
    mounted() {
      // let that = this;
      // var user = Promise.resolve(this.getUserInfo())
      // user.then(
      //   function (result) { 
      //   that.userInfo = result;
      //   that.getCompanyColleague(that.cpId);
      // })
      
    },
    methods: {

      // checkOK(msg){
      //   var userId = this.userInfo.uid
      //   var cp_id = msg[0]
      //   var check_userId = msg[1]
      //   this.$fetch(this.$path+ '/api.php/company/checkUserInCompany', {userId,cp_id,check_userId}).then((response) => {
      //     if(response.code == 200 ){
      //       MessageBox.alert(response.msg).then(action => {
      //         this.getCompanyColleague(this.cpId)
      //       }); 
      //     }else{
      //       MessageBox('提示', response.msg)
      //       return false
      //     }
      //   })
      // },
      //获取当前部门同等级的部门
      getCompanyDepartList(){
        this.$fetch(this.$path+ '/index.php/api/company/departList/'+this.deId+'/'+this.cpId).then((response) => {
          console.log('列表',response);
        })
      },
      //获取当前企业当前部门所有成员
      getCompanyColleague(cp_id){
        var userId = this.userInfo.uid
        var deId = this.deId
        let type = 1;//根据企业架构
        this.$fetch(this.$path+ '/api.php/company/getCompanyColleague', {cp_id,userId,type,deId}).then((response) => {
          console.log('所有成员',response);
          if(response.code == 200){
            // if(response.data.waitUserInfo!=''){
            //   for(var i in response.data.waitUserInfo){
            //     response.data.waitUserInfo[i]['userhead'] = this.$path+response.data.waitUserInfo[i]['userhead'];
            //   }
            // }
            // if(response.data.checkUserInfo!=''){
            //   for(var i in response.data.checkUserInfo){
            //     response.data.checkUserInfo[i]['userhead'] = this.$path+response.data.checkUserInfo[i]['userhead'];
            //   }
            // }

            this.waitUserInfo = response.data.waitUserInfo
            this.checkUserInfo = response.data.checkUserInfo
            if(!response.data.waitUserInfo.length){
              this.waitFlag1 = false
              this.waitFlag2 = true
            }
            if(response.data.checkUserInfo.length == 0){
              this.checkFlag1 = false
              this.checkFlag2 = true
            }
          }else{
            this.waitFlag1 = false
            this.waitFlag2 = true
            this.checkFlag1 = false
            this.checkFlag2 = true
          }
          if(response.data.isAdmin == 1){
            this.isAdmin = true
          }
        })
      },

      //查看申请用户
      goCheckInfo(lookUid){
        this.$router.push({path: '/colleagueInfo', query: {cp_id:this.cpId,lookUid:lookUid,checkFlag:this.type}});
      },
      //点击更多进入新同事审核
      auditlist() {
        this.$router.push({
          path: '/applicationList',
          query: {cp_id:this.cpId}
        })
      }
      //查看已审核用户
      // goInfo(lookUid){
      //   this.$router.push({path: '/colleagueInfo', query: {cp_id:this.cpId,lookUid:lookUid}}); 
      // },


    }
  }

</script>
<style >

/* .main-revie{
  background-color: #ffffff;
}
.main-revie span{
  float: left;
  margin-left: 15px;
  margin-top: 10px;
}
.main-revie ul{
  width:100%;
  margin: 0;
  padding: 0;
}
.main-revie ul li{
  width:100%;
  float: left;
  padding-left: 10px;
  padding-bottom: 10px;
  margin-top:15px;
  border-bottom: #d8d8d8 solid 1px;
}
.main-revie ul .active{
  border-bottom: none;
}
.main-revie ul li img{
    width: 45px;
    height: 45px;
    border-radius: 35px;
    float: left;
    margin: 5px;
} */
.main-center-join-list{
      text-align: left;
    margin-left: 2%;
    float: left;
    width:55%;
}
.main-center-join-list h5{
  font-size: 16px;
  margin: 0;
  padding: 0;
}
.main-center-join-list p{
  font-size: 14px;
  color:#999999;
}
.main-right {
  float: left;
  width: 20%;

}
.main-right .el-button {
    width: 60px;
    padding: 8px 10px;
    border-radius: 0;
    color: #fff;
    background:#ee7676;
}
.comColl{
  margin-top: 15px;
}

/* 我的同事 */

.main-myColl {
    background-color: #fff;
}

.noData {
    font-size: 0.34rem;
    color: #333;
}

.main-myColl .company_list .main-colleague {
    box-sizing: border-box;
    overflow: hidden;
}

.main-myColl .company_list .main-colleague>li {
    width: 1.02rem;
    border-right: none;
    margin-left: 0.2rem;
    padding-bottom: .2rem;
    float: left;
    box-sizing: border-box;
    margin-right: 0.28rem;
}

.main-myColl .company_list .main-colleague>li img {
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
}

/* 公司同事 */
.main-company-colleague {
  margin-top: 0.2rem;
}
</style>
